<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <c:set var="ctx" value="${pageContext.request.contextPath}"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>线索详情</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <form id="formSet1">
        <div class="fieldset1 tabel_col clearFix">
            <div class="caption">
                <span class="title">客户信息</span>
            </div>
            <div class="fieldBox col_50">
                <div class="label">客户姓名</div>
                <div class="field">
                    <span name="cstMgrNm" ><a
                            href="javascript:showDetail('${odrClueInfoVO.cstId}','${odrClueInfoVO.cstBscInfoVO.cstTypCd}')">${odrClueInfoVO.cstNm}</a>&nbsp;</span>
                </div>
            </div>

            <div class="fieldBox col_50">
                <div class="label">身份证</div>
                <div class="field">
                    <span name="cstMgrNm" >${odrClueInfoVO.cstBscInfoVO.certNo}&nbsp;</span>
                </div>
            </div>
            <div class="fieldBox col_50">
                <div class="label">性别</div>
                <div class="field">
                    <%--<span name="cstMgrNm" id="cstMgrNm">${odrClueInfoVO.cstBscInfoVO.cstNpBscInfoVO.mp1}&nbsp;</span>--%>
                    <span name="cstMgrNm" >${odrClueInfoVO.sex}&nbsp;</span>
                </div>
            </div>

            <div class="fieldBox col_50">
                <div class="label">注册手机号</div>
                <div class="field">
                    <span name="cstMgrNm" >${odrClueInfoVO.cstBscInfoVO.cstNpBscInfoVO.mp1}&nbsp;</span>
                </div>
            </div>

            <div class="fieldBox col_50">
                <div class="label">登录手机号</div>
                <div class="field">
                    <span>${odrClueInfoVO.usrMp}&nbsp;</span>
                </div>
            </div>

            <div class="fieldBox col_50">
                <div class="label">上牌时间</div>
                <div class="field">
                    <span name="licDt" id="licDt"><fmt:formatDate value="${odrClueInfoVO.licDt}"
                                                                  pattern="yyyy-MM-dd"/></span>
                </div>
            </div>

            <div class="fieldBox col_50">
                <div class="label">状态</div>
                <div class="field">
                    <span>${odrClueInfoVO.clueStsCdNm}</span>
                </div>
            </div>
            <div class="fieldBox col_50">
                <div class="label">一级推荐人</div>
                <div class="field">
                    <span name="cstMgrNm" >${odrClueInfoVO.oneMp}&nbsp;</span>
                </div>
            </div>
            <div class="fieldBox col_50">
                <div class="label">二级推荐人</div>
                <div class="field">
                    <span name="cstMgrNm" id="cstMgrNm">${odrClueInfoVO.twoMp}&nbsp;</span>
                </div>
            </div>
            
            <!-- 是否显示查询征信 -->
            <%-- 
            <sys:funcAuth resCd="CreditUpdate">
	            <div class="fieldBox col_50">
	                <div class="label">征信等级</div>
	                <div class="field">
	                	<span>${odrClueInfoVO.creditRstCd}</span>
	                </div>
	            </div>
	            
	            <div class="fieldBox col_50">
	                <div class="label">征信等级更新时间</div>
	                <div class="field">
	                    <span name="creditMdfTm" id="creditMdfTm">
	                    	<fmt:formatDate value="${odrClueInfoVO.creditMdfTm}" pattern="yyyy-MM-dd"/>
	                    </span>
	                </div>
	            </div>
			</sys:funcAuth>
			 --%>
			
            <div class="fieldBox col_100">
                <div class="label">备注</div>
                <div class="field">
                    <textarea name="odrRem" id="recordInfo" rows="6" class="ui-textarea l-textarea" style="width:80%"
                              value="" validate="{maxlength:200}">${odrClueInfoVO.odrRem}</textarea>
                </div>
            </div>
        </div>
    </form>
    <div class="btnsBox">
        <c:if test="${odrClueInfoVO.clueStsCd!='3' and odrClueInfoVO.clueStsCd!='4' }"> <span id="abandon" onclick="abandon()" class="sq-button sq-button-round">线索废弃</span></c:if>
        <c:if test="${odrClueInfoVO.clueStsCd!='3' and odrClueInfoVO.clueStsCd!='4' }"> <span id="rebeat" onclick="rebeat();" class="sq-button sq-button-round">已返利</span></c:if>
        <c:if test="${odrClueInfoVO.clueStsCd!='3' and odrClueInfoVO.clueStsCd!='4' }"> <span id="rebeat" onclick="done();" class="sq-button sq-button-round">已操作</span></c:if>
        <c:if test="${odrClueInfoVO.clueStsCd!='3' and odrClueInfoVO.clueStsCd!='4' }"> <span id="rebeat" onclick="floweUp();" class="sq-button sq-button-round">需跟进</span></c:if>
        <c:if test="${odrClueInfoVO.clueStsCd!='3' and odrClueInfoVO.clueStsCd!='4' }"> <span id="rebeat" onclick="turnUp();" class="sq-button sq-button-round">已流转</span></c:if>

        <span id="addbz" onclick="addbz();" class="sq-button sq-button-round" style="">添加备注</span>
        <%-- 
        <sys:funcAuth resCd="CreditUpdate">
        	<span id="addbz" onclick="updateCredit();" class="sq-button sq-button-round" style="">更新征信</span>
        </sys:funcAuth> --%>
        
    </div>

   <%-- ================================此处开始展示备注信息=======================================================--%>
    <br /><span style="display: inline-block; margin-top: 50px; margin-bottom: 15px;"><b>沟通记录</b></span>
    <div>
        <span>
            <c:if test="${empty remList}">无记录</c:if>
            <c:forEach var="i" items="${remList}">
                <div style="border: 1px solid #e9e9e9; background-color: #e7fef4; padding: 5px; ">
                <p style="margin-bottom: 5px;">  <c:out value="${i.crtUsrNm}"/> &nbsp;&nbsp;&nbsp;&nbsp;
                 <fmt:formatDate value="${i.crtTm}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></p>
                <p>记录：  <c:out value="${i.comment}"/></p>
                </div>
                <br />
            </c:forEach>
        </span>
    </div>
</div>


<script type="text/javascript">
    function viewAttachments(_id, _orgCd, _typeCd) {
        var urlArray = null;
        //alert(_id);
        $.ajax({
            type: 'get',
            dataType: 'json',
            data: {
                id: _id,
                orgCd: _orgCd,
                typeCd: _typeCd
            },
            url: '<%=path%>/carloan/odrClueInfoVO/viewAttachments.do',
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({
                    content: '正在查询图片...',
                    SQ_type: "waitting"
                });
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    //console.log(msg.data);
                    urlArray = msg.data;
                    if (urlArray != null && urlArray != "") {
                        for (img in urlArray) {
                            console.log(urlArray[img]);
                            var li = '<li><img  src="' + urlArray[img] + '" alt=""></li>';
                            $('#dowebok').append(li);
                        }
                        //$('#dowebok').viewer();
                        var viewer = new Viewer(document.getElementById('dowebok'), {
                            hidden: function () {
                                //alert('hidden');
                                urlArray = null;
                                $('#dowebok').html('');
                                viewer.destroy();
                            },
                        });
                        viewer.show();
                    } else {
                        $.ligerDialog.SQalert({
                            content: '该记录没有图片...',
                            SQ_type: "warn"
                        });
                    }
                } else {
                    $.ligerDialog.SQalert({
                        content: msg.info,
                        SQ_type: "error"
                    });
                }
            }
        });
    }

    //查看数据
    function showDetail(_id, _cstTypCd) {
        //1 自然人  2 法人
        if (_cstTypCd == 1) {
            parent.mainApp.f_addTab('tab_customer_np_detail' + _id, '客户详情', '<%=path%>/customer/cstbscinfo/toCustCstBacInfoNpDetailPage.do?id=' + _id);
        } else if (_cstTypCd == 2) {
            parent.mainApp.f_addTab('tab_customer_corp_detail' + _id, '客户详情', '<%=path%>/customer/cstbscinfo/toCustCstBacInfoCorpDetailPage.do?id=' + _id);
        }
    }

    /* 废弃线索*/
    function abandon() {
        $.ligerDialog.confirm('是否确认废弃?', function (flag) {
            if (flag == false) return;
            $.ajax({
                async: true,
                url: '<%=path%>/carloan/odrclueinfo/changeStatus.do',     // 后台取
                data: {
                	clueId:"${id}",
                    clueStsCd: 3
                },
                dataType: 'json',
                type: 'post',
                success: function (result) {
                    if (result.success == 1) {
                        $.ligerDialog.SQalert({content: "废弃成功", SQ_type: "success"});
                        Remove_navTab();
                    } else {
                        $.ligerDialog.SQalert({content: "废弃失败", SQ_type: "error"});
                    }

                },
                error: function (result) {
                    $.ligerDialog.SQalert({content: "废弃失败", SQ_type: "error"});
                }
            });
        })
    }

    /* 返利    $.ligerDialog.confirm(content, title, callback) */
    function rebeat() {
        $.ligerDialog.confirm('是否确认返利?', function (flag) {
            if (flag == false) return;
            $.ajax({
                async: true,
                url: '<%=path%>/carloan/odrclueinfo/changeStatus.do',     // 后台取
                data: {
                    clueId:"${id}",
                    clueStsCd: 4
                },
                dataType: 'json',
                type: 'post',
                success: function (result) {
                    if (result.success == 1) {
                        $.ligerDialog.SQalert({content: "返利成功", SQ_type: "success"});
                        Remove_navTab();
                    } else {
                        $.ligerDialog.SQalert({content: "返利失败", SQ_type: "error"});
                    }

                },
                error: function (result) {
                    $.ligerDialog.SQalert({content: "返利失败", SQ_type: "error"});

                }
            });
        })


    }

    function done() {
        $.ligerDialog.confirm('是否确认已操作?', function (flag) {
            if (flag == false) return;
            $.ajax({
                async: true,
                url: '<%=path%>/carloan/odrclueinfo/changeStatus.do',     // 后台取
                data: {
                    clueId:"${id}",
                    clueStsCd: 5
                },
                dataType: 'json',
                type: 'post',
                success: function (result) {
                    if (result.success == 1) {
                        $.ligerDialog.SQalert({content: "确认已操作成功", SQ_type: "success"});
                        Remove_navTab();
                    } else {
                        $.ligerDialog.SQalert({content: "确认已操作失败", SQ_type: "error"});
                    }

                },
                error: function (result) {
                    $.ligerDialog.SQalert({content: "确认已操作失败", SQ_type: "error"});
                }
            });
        })
    }



    function floweUp() {
        $.ligerDialog.confirm('是否确认需跟进?', function (flag) {
            if (flag == false) return;
            $.ajax({
                async: true,
                url: '<%=path%>/carloan/odrclueinfo/changeStatus.do',     // 后台取
                data: {
                    clueId:"${id}",
                    clueStsCd: 6
                },
                dataType: 'json',
                type: 'post',
                success: function (result) {
                    if (result.success == 1) {
                        $.ligerDialog.SQalert({content: "确认需跟进成功", SQ_type: "success"});
                        Remove_navTab();
                    } else {
                        $.ligerDialog.SQalert({content: "确认需跟进失败", SQ_type: "error"});
                    }

                },
                error: function (result) {
                    $.ligerDialog.SQalert({content: "确认需跟进失败", SQ_type: "error"});
                }
            });
        })
    }

    function turnUp() {
        $.ligerDialog.confirm('是否确认已流转?', function (flag) {
            if (flag == false) return;
            $.ajax({
                async: true,
                url: '<%=path%>/carloan/odrclueinfo/changeStatus.do',     // 后台取
                data: {
                    clueId:"${id}",
                    clueStsCd: 7
                },
                dataType: 'json',
                type: 'post',
                success: function (result) {
                    if (result.success == 1) {
                        $.ligerDialog.SQalert({content: "确认已流转成功", SQ_type: "success"});
                        Remove_navTab();
                    } else {
                        $.ligerDialog.SQalert({content: "确认已流转失败", SQ_type: "error"});
                    }

                },
                error: function (result) {
                    $.ligerDialog.SQalert({content: "确认已流转失败", SQ_type: "error"});
                }
            });
        })
    }

    /*添加备注 */
    function addbz() {
        var recordInfo = $("#recordInfo").val();
        if (recordInfo.trim() == "") {
            $.ligerDialog.alert("您尚未填写备注！");
            return;
        }
        $.ligerDialog.confirm('是否确认添加备注?', function (flag) {
            if (flag == false) return;
            $.ajax({
                async: true,
                url: '<%=path%>/carloan/odrclueinfo/addRem.do',     // 后台取
                data: {
                    clueId:"${id}",
                    odrRem: recordInfo
                },
                dataType: 'json',
                type: 'post',
                success: function (result) {
                    if (result.success == 1) {
                        $.ligerDialog.SQalert({content: "添加备注成功", SQ_type: "success"});
                        Remove_navTab();
                    } else {
                        $.ligerDialog.SQalert({content: "添加备注失败", SQ_type: "error"});
                    }
                },
                error: function () {
                    $.ligerDialog.SQalert({content: "添加备注失败", SQ_type: "error"});
                }
            });
        })
    }
    
    
    
    <%-- 
	//更新征信
    function updateCredit() {
		var cstNm = "${odrClueInfoVO.cstNm}";
		var certNo = "${odrClueInfoVO.cstBscInfoVO.certNo}";
		if(cstNm == null || cstNm == ""){
			$.ligerDialog.SQalert({content: "客户信息不完善：姓名不存在", SQ_type: "error"});
			return;
		}
		if(certNo == null || certNo == ""){
			$.ligerDialog.SQalert({content: "客户信息不完善：身份证号不存在", SQ_type: "error"});
			return;
		}
		
        $.ajax({
            async: true,
            url: '<%=path%>/carloan/odrclueinfo/updateOdrClueCredit.do',    
            data: {
                clueId:"${id}"
            },
            dataType: 'json',
            type: 'post',
            success: function (result) {
            	console.log("-----------------------------");
            	console.log(JSON.stringify(result));
                if (result.success == 1) {
                    $.ligerDialog.SQalert({content: "更新成功，请稍后刷新页面", SQ_type: "success"});
                    Remove_navTab();
                } else {
                    $.ligerDialog.SQalert({content: result.info, SQ_type: "warn"});
                }
            },
            error: function () {
                $.ligerDialog.SQalert({content: "更新失败！", SQ_type: "error"});
            }
        });
    }
 --%>

</script>
<style type="text/css">
    .viewer-container {
        transform: scale(0.6);
        -webkit-transform: scale(0.6);
        -moz-transform: scale(0.6);
        -o-transform: scale(0.6);
        -ms-transform: scale(0.6);
    }
</style>
</body>
</html>